<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function aaa() {
            // 获取所有input标签
            var eles = document.getElementsByTagName("input");
            var res = parseInt(eles[0].value) + parseInt(eles[1].value);
            document.getElementsByTagName("span")[0].innerHTML = res;
            document.getElementsByTagName("span")[0].style="color:red";
        }
        function checkNum(a) {
            if (isNaN(a)) {
                // 是  不是一个数字
                alert("请输入 数值");    
            }
        }

        alert(eval("1 + 1"));
        var str = "[1, 3, 5]";
        var as = eval(str);
        as.forEach(t => console.info(t))
    </script>
</head>
<body >
    <input onblur="checkNum(this.value)" /> +
    <input /> <button onclick="aaa()">=</button>
    <span></span>
</body>
</html>